package com.example.fbi_text.Acitivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import com.example.fbi_text.R;
//import com.example.fbi_text.adapter.AccountAdapter;
import com.example.fbi_text.bean.User;
import com.example.fbi_text.database.DBHelper;
import com.example.fbi_text.views.AccountFragment;
import com.example.fbi_text.views.AccountGroupView;

import java.util.List;

// 账号管理
public class AccountActivity extends AppCompatActivity {
    private ImageButton madd_account;
    private ImageView maccount_back;
    private ListView mAccountListView;
    private List<User> mUserList;
    private AlertDialog mDialog;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_account_list);
        initViews();
        initListeners();
        //嵌入 AccountFragment
        if (getSupportFragmentManager().findFragmentById(R.id.fragment_container) == null) {
            // 创建并添加 AccountFragment
            Fragment fragment = new AccountFragment();
            FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
            transaction.add(R.id.fragment_container, fragment);
            transaction.commit();
        }
    }

    private void initViews() {
        madd_account = findViewById(R.id.add_account);
        maccount_back = findViewById(R.id.account_back);
        mAccountListView = findViewById(R.id.account_list_view);
    }

    private void initListeners() {
        madd_account.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(AccountActivity.this, RegisterActivity.class);
                startActivity(intent);
            }
        });

        maccount_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}

